package com.fr.web.platform;

import com.fr.base.StringUtils;
import com.fr.base.XMLable;
import com.fr.base.core.BaseCoreUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.privilege.authentication.Authentication;
import com.fr.report.script.core.FArray;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public abstract class PlatformControl
  implements XMLable
{
  public static final String XML_TAG = "PlatformControl";
  private List authorityNameList = new ArrayList();

  public abstract boolean access(Authentication paramAuthentication);

  public abstract String getID();

  public int getAuthoryryNameCount()
  {
    return this.authorityNameList.size();
  }

  public void addAuthorityName(String paramString)
  {
    this.authorityNameList.add(paramString);
  }

  public String getAuthorityName(String paramString)
  {
    Iterator localIterator = this.authorityNameList.iterator();
    do
      if (!(localIterator.hasNext()))
        break label37;
    while (!(ComparatorUtils.equals(paramString, (String)localIterator.next())));
    return paramString;
    label37: return null;
  }

  public String getAuthorityName(int paramInt)
  {
    if ((paramInt < 0) || (paramInt > this.authorityNameList.size() - 1))
      return null;
    return ((String)this.authorityNameList.get(paramInt));
  }

  public void removeAuthorityName(String paramString)
  {
    this.authorityNameList.remove(paramString);
  }

  public void clearAuthority()
  {
    this.authorityNameList.clear();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
      this.authorityNameList.clear();
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("NameAttr"))
      {
        String str2 = paramXMLableReader.getAttr("names");
        Iterator localIterator = new FArray(str2.split(",")).iterator();
        while (true)
        {
          String str3;
          do
          {
            if (!(localIterator.hasNext()))
              return;
            str3 = (String)localIterator.next();
          }
          while (!(StringUtils.isNotBlank(str3)));
          this.authorityNameList.add(str3);
        }
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("PlatformControl");
    if (this.authorityNameList.size() > 0)
      paramXMLPrintWriter.startTAG("NameAttr").attr("names", BaseCoreUtils.join(this.authorityNameList, ",")).end();
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}